<template>
	<view class="content">
		<view class="passwordform">
			<u--form labelPosition="left" :model="passwordForm" :rules="rules" ref="uForm">
				<u-form-item label="输入密码" prop="upass" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.upass" border="none" type="password" placeholder="请输入密码" ></u--input>
				</u-form-item>
				<u-form-item label="确认密码" prop="subupass" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.subupass" border="none" type="password" placeholder="请输入确认密码" ></u--input>
				</u-form-item>
				<u-form-item label="邀请码" prop="invicate_code" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.invicate_code" border="none" placeholder="请输入邀请码" ></u--input>
				</u-form-item>
			</u--form>
			<view class="form_txt">1、设置的密码用于用户登录以及支付等操作，请妥善保管，避免遗失;</view>
			<view class="form_txt">2、输入邀请用户的邀请码，完成首单后即可获得对应邀请奖励,并加入邀请者团队,有机会获得团队返佣奖励。</view>
			<u-button type="primary" class="login_btn" text="继续" @click="copyMoney"></u-button>
		</view>
	</view>
</template>

<script>
	import botLine from '../../components/botLine.vue'
	export default {
		components:{
			botLine
		},
		data() {
			return {
				passwordForm : {
					upass : '',
					subupass : '',
					invicate_code : '',
					public_key : '',
					private_key : '',
					usdt_address : '',
				},
				rules:{
					upass: [
					  { required: true,validator: function(rule, value, callback){
						 if (value == '') {
							 callback(new Error('请输入新密码'))
						 }else if (value.length < 8) {
						  callback(new Error('请输入至少8位的密码'))
						 }else if (
							!/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@!*#$%&_=])[A-Za-z\d@!*#$%&_=]{8,18}$/.test(value)
						 ) {
							callback(new Error('密码必须包含字母、数字和特殊字符(@!*#$%&_=)'))
						 }
						 else{
							  callback();
						 }
					  }, trigger: 'blur' }
					],
					subupass: [
					  { required: true,validator: function(rule, value, callback){
						 if (value == '') {
						  // console.log('value',value)
						  // console.log('upass',this.passwordForm.upass)
						  // console.log('value',value != this.passwordForm.upass)
								callback(new Error('请输入确认密码'))
						 }else if (value.length < 8) {
								callback(new Error('请输入至少8位确认密码'))
						 }else if (value != this.passwordForm.upass) {
								callback(new Error('两次输入的新密码不一致'))
						 }
						 else {
						  	  callback();
						 }
					  }, trigger: 'blur' },
					]
				}
			}
		},
		onLoad() {
			this.passwordForm.upass = '';
			this.passwordForm.subupass = '';
			this.passwordForm.invicate_code = '';
			this.passwordForm.public_key = '';
			this.passwordForm.private_key = '';
			this.passwordForm.usdt_address = '';
		},
		methods: {
			copyMoney(v){
				this.$refs.uForm.validate().then(res =>{
					sessionStorage.setItem('passwordForm', JSON.stringify(this.passwordForm))
					uni.navigateTo({
					    url:`../copyMoney/index?content=${this.title}`
					});
				}).catch(error=>{
					
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
.content{padding:0 20rpx ;
	height: 100vh;background-color: #f1f5f8;
	.passwordform{
		padding-top: 20rpx;
		.itemform{
			margin-bottom:20rpx;font-weight: 400;
			/deep/.u-form-item__body{
				background-color: #fff;padding-left:10rpx;padding-right:10rpx;
			}
		}
	}
	.form_txt{
		font-size: 24rpx;color: #94989b;line-height: 46rpx;
	}
	
	
	
	
	
	
	.login_btn{background-color: $btnColor;border: $btnColor solid 1px;width:95%;margin:100rpx auto 0;}
}
</style>